package com.yan.work;

import com.yan.domain.Hero;

import java.util.Scanner;

public class Test5 {
    public static final int MIN = 10;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Hero hero1 = new Hero("yft", 5 , 0 , 140);
        Hero hero2 = new Hero("hpy" , 4 , 0 , 110);
        int fight = 0;
        while(true){
            if(hero1.getBlood() <= MIN){
                System.out.println("血量过低,是否退出战斗(y/n)");
                String choice = scanner.next();
                if(choice.equals("y")){
                    break;
                }
            }
            if(hero2.getBlood() <= MIN){
                System.out.println("血量过低,是否退出战斗(y/n)");
                String choice = scanner.next();
                if(choice.equals("y")){
                    break;
                }
            }
            if(hero1.getBlood() <= 0){
                hero1.fightOver(false);
                hero2.fightOver(true);
                break;
            }
            if(hero2.getBlood() <= 0){
                hero1.fightOver(true);
                hero2.fightOver(false);
                break;
            }
            fight = hero1.attack();
            hero2.setBlood(hero2.getBlood() - fight);
            fight = hero2.attack();
            hero1.setBlood(hero1.getBlood() - fight);

            hero1.status();
            hero2.status();

        }
        System.out.println("最终结果");
        hero1.status();
        hero2.status();
    }
}

